#ifndef BASE_FUNC_H
#define BASE_FUNC_H

#include "includes.h"

typedef struct vdata_sem_t{
    sem_t sem_id;
    uint8_t *sem_data;
}vdata_sem_t;

uint8_t chr2hex(uint8_t chr);
uint8_t hex2chr(uint8_t hex);
int16_t str2dec(const char *s);
uint16_t crc16(uint8_t *puchMsg, uint16_t usDataLen);
uint16_t crc16_1(uint16_t checksum, uint8_t *puchMsg, uint16_t usDataLen);

void word_high_low_sw(uint16_t *data, uint16_t length);

int sleep_ms(double sleep_time);

uint8_t *parse_sem_post(vdata_sem_t *sem, uint8_t *value);
uint8_t parse_sem_pend(vdata_sem_t *sem, uint16_t msec);
#endif // BASE_FUNC_H
